home *** CD-ROM | disk | FTP | other *** search
/ PCMania 73 / PCMania CD73_1.iso / pcmania / demosc73 / CFADE2.PAS < prev    next >
Pascal/Delphi Source File  |  1998-09-30  |  3KB  |  100 lines

  1.  
  2. { HEY! PcManíacos:                                               }
  3.  
  4. { Si queréis contactar con el autor de esta sección,             }
  5. { ahora podéis hacerlo a través de su e-mail privado:            }
  6.  
  7. { Miquel Barceló: (Demoscene)                                    }
  8. {                               e-mail: MBarceloJ@nexo.es        }
  9.  
  10. { -------------------------------------------------------------- }
  11.  
  12.  
  13. {$N+,E+}
  14.  
  15. uses dos,crt,graf;
  16.  
  17. var
  18.    mixpant  : pointer;
  19.    pant1    : pointer;
  20.    pant2    : pointer;
  21.    pal1     : paleta;
  22.    pal2     : paleta;
  23.    palcf1   : paleta;
  24.    palcf2   : paleta;
  25.    conta    : word;
  26.  
  27.  
  28. procedure calc_mix_pant(var p1,p2; pal1,pal2:paleta);
  29. var
  30.    cont   : word;
  31.    mixcol : byte;
  32.  
  33. begin
  34.      for cont:=0 to 63999 do
  35.      begin
  36.           mixcol:=((MEM[seg(p1):ofs(p1)+cont] and 15)shl 4)+
  37.                    (MEM[seg(p2):ofs(p2)+cont] and 15);
  38.  
  39.           MEM[seg(mixpant^):ofs(mixpant^)+cont]:=mixcol;
  40.      end;
  41.      for cont:=0 to 255 do
  42.      begin
  43.           palcf1[cont]:=pal1[(cont shr 4) and 15];
  44.           palcf2[cont]:=pal2[cont and 15];
  45.      end;
  46. end;
  47.  
  48.  
  49. procedure set_crossfade(pal1,pal2 : paleta; percent : word);
  50. VAR
  51.    cont   : word;
  52.    palm     : paleta;
  53.  
  54. begin
  55.      for cont:=0 to 255 do
  56.      begin
  57.           palm[cont].r:=(percent*pal1[cont].r+(256-percent)*pal2[cont].r)shr 8;
  58.           palm[cont].g:=(percent*pal1[cont].g+(256-percent)*pal2[cont].g)shr 8;
  59.           palm[cont].b:=(percent*pal1[cont].b+(256-percent)*pal2[cont].b)shr 8;
  60.      end;
  61.      esperavga;
  62.      putpaleta(palm);
  63. end;
  64.  
  65. begin
  66.      getmem (pant1,64000);
  67.      getmem (pant2,64000);
  68.      getmem (mixpant,64000);
  69.  
  70.      set_vga;
  71.      load_PCX('birdy.pcx',pant1^);
  72.      getpaleta(pal1);
  73.      load_PCX('pcmania2.pcx',pant2^);
  74.      getpaleta(pal2);
  75.  
  76.      calc_mix_pant(pant1^,pant2^,pal1,pal2);
  77.  
  78.      flip (mixpant^,vga^);
  79.      for conta:=0 to 255 do putrgb(conta,(conta and 15) shl 2,0,((conta shr 4)and 15)shl 2);
  80.      readkey;
  81.      repeat
  82.            conta:=0;
  83.            repeat
  84.                  inc (conta);
  85.                  set_crossfade(palcf1,palcf2,256*conta div 100);
  86.            until (keypressed) or (conta=100);
  87.            conta:=0;
  88.            repeat
  89.                  inc (conta);
  90.                  set_crossfade(palcf2,palcf1,256*conta div 100);
  91.            until (keypressed) or (conta=100);
  92.  
  93.      until keypressed;
  94.      set_text;
  95.      freemem (pant1,64000);
  96.      freemem (pant2,64000);
  97.      freemem (mixpant,64000);
  98. end.
  99.  
  100.